package momo.multitree.simulation.decentralized;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import momo.multitree.algo.decentralized.LatencyShortestPathDecent;
import momo.multitree.structure.Graph;
import momo.multitree.structure.Tree;
import momo.multitree.util.JackAlgo;

public class SimulationDecentWorker
{
	private Log log = LogFactory.getLog(this.getClass());
	private Graph orgGraph;
	private Tree bestLatTree;
	private JackAlgo algo;
	private DijkstraValidatorDecent validator;
	
	public SimulationDecentWorker(Graph g)
	{
		orgGraph = g;
		LatencyShortestPathDecent latTest = new LatencyShortestPathDecent();
		bestLatTree = latTest.optimumTree(orgGraph);
		
		algo = new JackAlgo();
		
		validator = new DijkstraValidatorDecent(bestLatTree);
		algo.addVisitor(validator);
	}
	
	public String run()
	{
		algo.generateSpanningGraph(orgGraph);
		return validator.toString();
	}
}//end of class SimulationDecentWorker
